/*
 *  $Id: MothTouch.cs 939 2009-12-03 13:12:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Air.Abilities {
    public class MothTouch: AbilityCard<Creature> {
        public MothTouch(): base("001_a_a_moth_touch") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Air;
            Target = new CreatureTarget(GetTargetPhrase(), true, true, IsNeighbor);
        }

        private static bool IsNeighbor(TargetRequest request, Creature target) {
            Creature caster = request.Caster as Creature;
            if (caster == null || caster.DistanceTo(target) > 1) return false;
            if (caster.Owner != target.Owner && caster.Owner.GetMana(ElementType.Air) < 1) return false;
            return true;
        }

        protected override void DoAction(TargetArgs<Creature> args) {
            if (args.Target.Owner != args.Player) args.Player.DecrementMana(ElementType.Air, 1);
            args.Target.AddAffect<MothTouchAffect>();
        }

        private class MothTouchAffect: SpellAffect<MothTouch> {
            public MothTouchAffect(): base() {
                Add(new TimeAffect(4, new Affects.ModMaxHealth(-1)));
            }
        }
    }
}
